<template>
  <div class="toast" v-show="isshow">
    <div>{{ message }}</div>
  </div>
</template>

<script>
export default {
  name: "toast",
  props: {},
  data() {
    return {
      message: "",
      isshow: false,
    };
  },
  methods: {
    show(message = "默认属性", timeout = 2000) {
      this.isshow = true;
      this.message = message;
      setTimeout(() => {
        this.isshow = false;
      }, timeout);
    },
  },
};
</script>

<style scoped>
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  padding: 8px 10px;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9999999;
}
</style>